﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace AsyncUnitTest
{
    public class MyTest6
    {
        public static void Go()
        {
            for (int i = 1; i <= 500; i++)
            {
                Console.WriteLine($" {i}  ");
                int j = i;//拿到当前应该用的i，直接使用i会导致线程安全问题
                Task.Run(() =>
                {
                    Console.WriteLine($" {j}  任务开始...");
                    Thread.Sleep(100);
                });
            }
            Thread.Sleep(5000);
        }
    }
}
